<?php
                                                                                                                                                                                                                                                                                                                                        
// TTTTTTTTTTTTTTTTTTTTTTT                  MMMMMMMM               MMMMMMMM                                CCCCCCCCCCCCMMMMMMMM               MMMMMMMM  SSSSSSSSSSSSSSS 
// T:::::::::::::::::::::T                  M:::::::M             M:::::::M                             CCC::::::::::::M:::::::M             M:::::::MSS:::::::::::::::S
// T:::::::::::::::::::::T                  M::::::::M           M::::::::M                           CC:::::::::::::::M::::::::M           M::::::::S:::::SSSSSS::::::S
// T:::::TT:::::::TT:::::T                  M:::::::::M         M:::::::::M                          C:::::CCCCCCCC::::M:::::::::M         M:::::::::S:::::S     SSSSSSS
// TTTTTT  T:::::T  TTTTTppppp   ppppppppp  M::::::::::M       M::::::::::M   eeeeeeeeeeee          C:::::C       CCCCCM::::::::::M       M::::::::::S:::::S            
//         T:::::T       p::::ppp:::::::::p M:::::::::::M     M:::::::::::M ee::::::::::::ee       C:::::C             M:::::::::::M     M:::::::::::S:::::S            
//         T:::::T       p:::::::::::::::::pM:::::::M::::M   M::::M:::::::Me::::::eeeee:::::ee     C:::::C             M:::::::M::::M   M::::M:::::::MS::::SSSS         
//         T:::::T       pp::::::ppppp::::::M::::::M M::::M M::::M M::::::e::::::e     e:::::e     C:::::C             M::::::M M::::M M::::M M::::::M SS::::::SSSSS    
//         T:::::T        p:::::p     p:::::M::::::M  M::::M::::M  M::::::e:::::::eeeee::::::e     C:::::C             M::::::M  M::::M::::M  M::::::M   SSS::::::::SS  
//         T:::::T        p:::::p     p:::::M::::::M   M:::::::M   M::::::e:::::::::::::::::e      C:::::C             M::::::M   M:::::::M   M::::::M      SSSSSS::::S 
//         T:::::T        p:::::p     p:::::M::::::M    M:::::M    M::::::e::::::eeeeeeeeeee       C:::::C             M::::::M    M:::::M    M::::::M           S:::::S
//         T:::::T        p:::::p    p::::::M::::::M     MMMMM     M::::::e:::::::e                 C:::::C       CCCCCM::::::M     MMMMM     M::::::M           S:::::S
//       TT:::::::TT      p:::::ppppp:::::::M::::::M               M::::::e::::::::e                 C:::::CCCCCCCC::::M::::::M               M::::::SSSSSSS     S:::::S
//       T:::::::::T      p::::::::::::::::pM::::::M               M::::::Me::::::::eeeeeeee          CC:::::::::::::::M::::::M               M::::::S::::::SSSSSS:::::S
//       T:::::::::T      p::::::::::::::pp M::::::M               M::::::M ee:::::::::::::e            CCC::::::::::::M::::::M               M::::::S:::::::::::::::SS 
//       TTTTTTTTTTT      p::::::pppppppp   MMMMMMMM               MMMMMMMM   eeeeeeeeeeeeee               CCCCCCCCCCCCMMMMMMMM               MMMMMMMMSSSSSSSSSSSSSSS   
//                        p:::::p                                                                                                                                       
//                        p:::::p                                                                                                                                       
//                       p:::::::p                                                                                                                                      
//                       p:::::::p                                                                                                                                      
//                       p:::::::p                                                                                                                                      
//                       ppppppppp                                                                                                                                      
                                                                                                                                                                     
//  _____      __  __         ____ __  __ ____  
// |_   __ __ |  \/  | ___   / ___|  \/  / ___|     | AUTHOR: Xiaohe
//   | || '_ \| |\/| |/ _ \ | |   | |\/| \___ \     | EMAIL: 496631085@qq.com
//   | || |_) | |  | |  __/ | |___| |  | |___) |    | WECHAT: he4966
//   |_|| .__/|_|  |_|\___|  \____|_|  |_|____/     | DATETIME: 2021/07/27
//      |_|                                         | TpMeCMS

namespace app\api\controller;
use app\api\controller\Tpmecms;
use think\Db;
use think\Config;
/**
 * 公共无需登陆接口
 */
class Com extends Tpmecms
{

    // 无需登录的接口,*表示全部
    protected $noNeedLogin = ['*'];
    // 无需鉴权的接口,*表示全部
    protected $noNeedRight = ['*'];

    /**
     * 数据库介绍
     *
     * @return void
     */
    public function db()
    {
       $data = ['表名'=>'说明文档',
                'car'   => '汽车管理(城市快速，拉货搬家）',
                'car'   =>  '整车发货价格管理',
                'order1'=>'普通发货订单',
                'order2'=>'运货搬家订单',

                'bulkload2' => '零担(超高超长)',
                'bulkload' => '零担 价格'];
       $this->success('数据库结束',$data);  
    }

    /**
     * 附近XX
     *
     * @return void
     */
    protected function geo()
    {
        return  new \addons\redisgeo\controller\Index();
    }


    /**
     * 获取配置🚚
     *
     * @param string $field 获取需要的字段例如name（可不传获取全部
     * @return void
     */
    public function get_config($field = null)
    {
        if($field){
            $this->success($field,Config::get('site.'.$field));
        }else{
            $this->success('all',Config::get('site'));
        }
    }

    /**
     * 获取banner🚚
     *
     * @return void
     */
    public function get_banner()
    {
        $this->success('ok',Db::name('banner')->order('weigh desc')->select());
    }

    /**
     * 测试
     *
     * @param string $str 搜索内容
     * @return void
     */
    public function test($str = 'xiao')
    {
        $where['username|nickname'] = ['LIKE','%'.$str.'%'];
        $list = Db::name('user')
            ->where($where)
            ->select();
        $this->success('ok',$list);
    }

    /**
     * 获取货物列表🗃
     *
     * @param int $cargocate_id 货物分类id(可不传)
     * @return void
     */
    public function get_cargo_list($cargocate_id=null)
    {
        //  
        $where = null;
        if($cargocate_id){
            $where['cargocate_id'] = $cargocate_id;
        }
        $list = Db::name('cargo')->where($where)->select();
        $this->success('ok',$list);
    }

    /**
     * 获取货物分类🗃
     *
     * @return void
     */
    public function get_cargocate()
    {
        $list = Db::name('cargocate')->select();
        $this->success('ok',$list);
    }




    


    // GetCargoList



    /**
     * 获取普通发货标签列表
     *
     * @return void
     */
    public function get_tag_list()
    {
         $this->success('ok',$this->GetTagList());
    }

    /**
     * 获取城市搬家发货标签列表
     *
     * @return void
     */
    public function get_tag2_list()
    {
         $this->success('ok',$this->GetTag2List());
    }


    /**
     * 获取汽车列表🚚
     *
     * @return void
     */
    public function get_car_list()
    {
        $this->success('ok',Db::name('car')->select());
    }

    /**
     * 获取汽车信息🚚
     *
     * @return void
     */
    public function get_car_data($id)
    {
        $this->success('ok',Db::name('car')->find($id));
    }

    /**
     * 获取最新订单消息列表
     *
     * @param integer $limit
     * @return void
     */
    public function get_new_order_msg_list($limit=10)
    {
        // $order1 = Db::name('order1')
        //         ->where('status',2)
        //         ->where('s_uid','>',0)
        //         ->where('j_uid','>',0)
        //         ->order('j_time desc')
        //         ->limit($limit)
        //         ->select();

        // $order2 = Db::name('order2')
        //         ->where('status',2)
        //         ->where('s_uid','>',0)
        //         ->where('j_uid','>',0)
        //         ->order('j_time desc')
        //         ->limit($limit)
        //         ->select();

        // $order4 = Db::name('order4')
        //         ->where('status',2)
        //         ->where('s_uid','>',0)
        //         ->where('j_uid','>',0)
        //         ->order('j_time desc')
        //         ->limit($limit)
        //         ->select();

        // $list = Db::name('pay_order')
        //             ->where('pay_status','2')//支付状态:1=待支付,2=已支付,3=已退款,4=已超时
        //             ->where('role_status','2')//角色:1=货主,2=司机
        //             ->order('desc pay_time')
        //             ->select();
        // foreach ($list as $key => $val) {
        //     $count = Db::name('pay_order')->where('order_id',$val['order_id'])->where('order_status',$val['order_status'])->where('pay_status',2)->count();
        //     if($count==2){
                
        //         switch ($val['order_status']) {//订单类型:1=普通发货,2=城市快运,3=拉货搬家,4=顺风车
        //             case '1':
        //                 Db::name('order1')
        //                 break;
                    
        //             default:
        //                 # code...
        //                 break;
        //         }
        //         $msg_arr[] = $ 
        //     }
        // }
        
    }

    /**
     * 获取汽车2列表🛻🚛
     *
     * @return void
     */
    public function get_car2_list()
    {
        $this->success('ok',Db::name('car2')->select());
    }

    /**
     * 获取汽车2信息🛻🚛
     *
     * @return void
     */
    public function get_car2_data($id)
    {
        $this->success('ok',Db::name('car2')->find($id));
    }





//  _____      __  __         ____ __  __ ____  
// |_   __ __ |  \/  | ___   / ___|  \/  / ___|     | AUTHOR: Xiaohe
//   | || '_ \| |\/| |/ _ \ | |   | |\/| \___ \     | EMAIL: 496631085@qq.com
//   | || |_) | |  | |  __/ | |___| |  | |___) |    | WECHAT: he4966
//   |_|| .__/|_|  |_|\___|  \____|_|  |_|____/     | DATETIME: 2021/09/2
//      |_|                                         | TpMeCms 🛢Start

    /**
     * 获取油型号列表🛢
     *
     * @return void
     */
    public function get_oil_list()
    {
       $this->success('ok',Db::name('oil')
                ->order('weigh desc')
                ->select());
    }

    // /**
    //  * 获取加油站列表🛢
    //  *
    //  * @return void
    //  */
    // public function get_pfs_list()
    // {
    //    $this->success('ok',Db::name('pfs')
    //             // ->order('weigh desc')
    //             ->select());
    // }

    /**
     * 搜索加油站🛢
     *
     * @param int $page 1
     * @param int $limit 10
     * @param string $name 加油站名
     * @param string $lat 纬度
     * @param string $lng 经度
     * @param int $oil_id 油型号id
     * @return void
     */
    public function search_pfs_list($page=1,$limit=10,$name=null  ,$oil_id = null, $lat=null,$lng=null)
    {
        $where['switch'] = 1;
        if($name){
            $where['name'] = ['like',"%".$name."%"];
        }
        if($oil_id){
            $pfs_ids = Db::name('pfs_price')->where('oil_id',$oil_id)->column('pfs_id');
            $where['id'] = ['in',$pfs_ids];
        }
       
        $list_ids = Db::name('pfs')
            ->where($where)
            // ->page($page,$limit)
            ->column('id');
        //如果没有条件 距离里面也不用执行了
        if($list_ids)
        if($lat && $lng){           

            $list_geo = $this->GetNearbyGeoPfs($lng,$lat);//附近加油站  //,5000,'km',99999,'ASC','geo_pfs'
            
            $geo_ids = array();//   关联查询
            $geo_arr = array();//距离数组
            foreach ($list_geo as $key => $val) {
                $id = $val[0];
                $geo_arr[$id] = $val[1];//距离数组
                if(in_array($id,$list_ids)){    //在附近里面就加入关联查询

                    $geo_ids[] = $id;
                }
                
            }
            if($geo_ids)
            $where['id'] = ['in',$geo_ids];
        }

      
        //查询分页  /距离条件
        $list = Db::name('pfs')
            ->where($where)
            ->page($page,$limit)
            ->select();           

        if($list){
            foreach ($list as $key => &$val) {
                $val['pfs_price'] = $this->GetPfsPrice($val['id']);
                if(!$lat || !$lng){
                    $val['km'] = null;
                }else{
                    $val['km'] = $geo_arr[$val['id']];
                    //计算距离
                }
                
            }
        }
        $this->success('ok',$list);
    }


    /**
     * 获取加油站信息🛢
     *
     * @param int $id 加油站id
     * @return void
     */
    public function get_pfs_data($id)
    {
        $this->success('ok',$this->GetPfsDataById($id));
    }



//  _____      __  __         ____ __  __ ____  
// |_   __ __ |  \/  | ___   / ___|  \/  / ___|     | AUTHOR: Xiaohe
//   | || '_ \| |\/| |/ _ \ | |   | |\/| \___ \     | EMAIL: 496631085@qq.com
//   | || |_) | |  | |  __/ | |___| |  | |___) |    | WECHAT: he4966
//   |_|| .__/|_|  |_|\___|  \____|_|  |_|____/     | DATETIME: 2021/09/2
//      |_|                                         | TpMeCms 🛢End







//  _____      __  __         ____ __  __ ____  
// |_   __ __ |  \/  | ___   / ___|  \/  / ___|     | AUTHOR: Xiaohe
//   | || '_ \| |\/| |/ _ \ | |   | |\/| \___ \     | EMAIL: 496631085@qq.com
//   | || |_) | |  | |  __/ | |___| |  | |___) |    | WECHAT: he4966
//   |_|| .__/|_|  |_|\___|  \____|_|  |_|____/     | DATETIME: 2021/09/14
//      |_|                                         | TpMeCms  🚛🚛物流专线Start

    /**
     * 获取物流专线全部路线🚛🚛
     *
     * @param int $s_area_id 出发地id(可不传)
     * @param int $e_area_id 目的地id(可不传)
     * @return void
     */
    public function get_all_route($s_area_id=null,$e_area_id=null)
    {
        $list = $this->GetAllRoute($s_area_id,$e_area_id);
        $this->success('ok',$list);
    }

    /**
     * 获取物流专线列表🚛🚛
     *
     * @param int $s_area_id 出发地id(可不传)
     * @param int $e_area_id 目的地id(可不传)
     * @param int $lat 纬度(可空)
     * @param int $lng 经度(可空)
     * @return void
     */
    public function get_logistics_list($s_area_id=null,$e_area_id=null,$lat=null,$lng=null)
    {
        // $list = $this->GetAllRoute($s_area_id,$e_area_id);
        $list = [];

        if($s_area_id && $e_area_id){
            // $list = $this->GetAllRoute($s_area_id,$e_area_id);
            if($s_area_id){
                $where['s_area_id'] = ['=',$s_area_id];
            }
            if($e_area_id){
                $where['e_area_id'] = ['=',$e_area_id];
            }
    
            $route_ids = Db::name('route')->where($where)->column('id');
            $logistics_ids = Db::name('logistics_route')->where('route_id','in',$route_ids)->column('logistics_id');
            
            
            foreach ($logistics_ids as $key => $id) {
                $list[]  = $this->GetLogisticsDataById($id);
            }

        }else{
            $logistics_ids = Db::name('logistics')->where('switch','1')->column('id');
            foreach ($logistics_ids as $key => $id) {
               
                $val  = $this->GetLogisticsDataById($id);

                $val['km'] = 0;
                if($lat && $lng){
                    $val['km'] = round($this->get_coordinate_distance($lng,$lat,$val['lng'],$val['lat']),2);
                }
                $list[] = $val;
            }
        }

        $this->success('ok',$list);
    }


    /**
     * 获取路线的物流专线列表
     *
     * @param int $route_id 路线id
     * @param int $lat 纬度(可空)
     * @param int $lng 经度(可空)
     * 
     * @return void
     */
    public function get_route_logistics_list($route_id,$lat=null,$lng=null)
    {
        $logistics_ids = Db::name('logistics_route')->where('route_id',$route_id)->column('logistics_id');
        if(!$logistics_ids){
            $this->error('没有');
        }

        $list = Db::name('logistics')->where('id','in',$logistics_ids)->select();
        foreach ($list as $key => &$val) {
            $val['km'] = 0;
            if($lat && $lng){
                $val['km'] = round($this->get_coordinate_distance($lng,$lat,$val['lng'],$val['lat']),2);
            }
            
        }
        $this->success('ok',$list);
        


    }

    /**
     * 获取物流专线信息
     *
     * @param int $logistics_id 物流专线id
     * @return void
     */
    public function get_logistics_data($logistics_id)
    {
        $this->success('ok',$this->GetLogisticsDataById($logistics_id));
    }
  




//  _____      __  __         ____ __  __ ____  
// |_   __ __ |  \/  | ___   / ___|  \/  / ___|     | AUTHOR: Xiaohe
//   | || '_ \| |\/| |/ _ \ | |   | |\/| \___ \     | EMAIL: 496631085@qq.com
//   | || |_) | |  | |  __/ | |___| |  | |___) |    | WECHAT: he4966
//   |_|| .__/|_|  |_|\___|  \____|_|  |_|____/     | DATETIME: 2021/09/14
//      |_|                                         | TpMeCms 🚛🚛物流专线End






//  _____      __  __         ____ __  __ ____  
// |_   __ __ |  \/  | ___   / ___|  \/  / ___|     | AUTHOR: Xiaohe
//   | || '_ \| |\/| |/ _ \ | |   | |\/| \___ \     | EMAIL: 496631085@qq.com
//   | || |_) | |  | |  __/ | |___| |  | |___) |    | WECHAT: he4966
//   |_|| .__/|_|  |_|\___|  \____|_|  |_|____/     | DATETIME: 2021/09/15
//      |_|                                         | TpMeCms 🛻二手车Start

/**
 * 获取二手车品牌列表🛻
 *
 * @return void
 */
public function get_carbrand_list()
{
    $this->success('ok',$this->GetCarbrandList());
}


/**
 * 获取二手车类型列表🛻
 *
 * @return void
 */
public function get_cartype_list()
{
    $this->success('ok',$this->GetCartypeList());
}




/**
 * 获取二手车列表🛻
 *
 * @param int $page 1 
 * @param int $limit 10
 * @param int $carbrand_id 品牌id
 * @param int $cartype_id 车辆类型id
 * @param int $price 价格区间 1=0-5万,2=5-10,3=10-20,4=20-40,5=40w以上
 * @return void
 */
public function get_used_car_list($page=1,$limit=10,$carbrand_id=null,$cartype_id=null,$price=null)
{
    $where['switch'] = 1;

    $used_car_list = Db::name('used_car')->where($where)->select();
    foreach ($used_car_list as $key => &$val) {
        //$val['route_name'] = Db::name('route')->where('id',$val['route_id'])->value('name');
    }
    return $used_car_list;
}



/**
 * 获取二手车信息🛻
 *
 * @param int $id 二手车id
 * 
 * @return void
 */
public function get_used_car_data($id)
{
    $this->success('ok',$this->GetUsedCarData($id));
}


//  _____      __  __         ____ __  __ ____  
// |_   __ __ |  \/  | ___   / ___|  \/  / ___|     | AUTHOR: Xiaohe
//   | || '_ \| |\/| |/ _ \ | |   | |\/| \___ \     | EMAIL: 496631085@qq.com
//   | || |_) | |  | |  __/ | |___| |  | |___) |    | WECHAT: he4966
//   |_|| .__/|_|  |_|\___|  \____|_|  |_|____/     | DATETIME: 2021/09/15
//      |_|                                         | TpMeCms 🛻二手车End








//  _____      __  __         ____ __  __ ____  
// |_   __ __ |  \/  | ___   / ___|  \/  / ___|     | AUTHOR: Xiaohe
//   | || '_ \| |\/| |/ _ \ | |   | |\/| \___ \     | EMAIL: 496631085@qq.com
//   | || |_) | |  | |  __/ | |___| |  | |___) |    | WECHAT: he4966
//   |_|| .__/|_|  |_|\___|  \____|_|  |_|____/     | DATETIME: 2021/09/15
//      |_|                                         | TpMeCms 🍀距离Start



    /**
     * 计算距离
     *
     * @param int $s_area_id 发货地址id
     * @param int $e_area_id 卸货地址id
     * @return void
     */
    public function calculate_distance($s_area_id,$e_area_id)
    {
        $this->success('ok',$this->CalculateDistance($s_area_id,$e_area_id));
    }


    /**
     * 计算全部距离
     *
     * @param int $s_addr_id 装货地址
     * @param int $s2_addr_id 装货地址2
     * @param int $e_addr_id 卸货地址
     * @param int $e2_addr_id 卸货地址2  
     * @return void
     */
    public function calculate_distance_all($s_addr_id,$s2_addr_id=null,$e_addr_id,$e2_addr_id=null)
    {
        // $km = 0;
        // if($s2_addr_id){
        //     $km = $this->CalculateDistance($s_addr_id,$s2_addr_id);
        //     $km = $km + $this->CalculateDistance($s2_addr_id,$e_addr_id);
          
        //     if($e2_addr_id){
        //         $km = $km + $this->CalculateDistance($e_addr_id,$e2_addr_id);
        //     }
        // }else{
          
        //     $km = $this->CalculateDistance($s_addr_id,$e_addr_id);
        //     if($e2_addr_id){
        //         $km = $km + $this->CalculateDistance($e_addr_id,$e2_addr_id);
        //     }
        // }
        $this->success('ok',$this->CalculateDistanceAll($s_addr_id,$s2_addr_id ,$e_addr_id,$e2_addr_id));
    }

    /**
     * 计算全部距离2
     *
     * @param string $addr_ids 地址id按顺序排列例如1,3,2
     * @return void
     */
    public function calculate_distance_all2($addr_ids)
    {
        $addr_ids = explode(',',$addr_ids);
     
        $this->success('ok',$this->CalculateDistanceAll2($addr_ids));
    }


//  _____      __  __         ____ __  __ ____  
// |_   __ __ |  \/  | ___   / ___|  \/  / ___|     | AUTHOR: Xiaohe
//   | || '_ \| |\/| |/ _ \ | |   | |\/| \___ \     | EMAIL: 496631085@qq.com
//   | || |_) | |  | |  __/ | |___| |  | |___) |    | WECHAT: he4966
//   |_|| .__/|_|  |_|\___|  \____|_|  |_|____/     | DATETIME: 2021/09/15
//      |_|                                         | TpMeCms 🍀距离End


    // /**
    //  * 获取全部路线🚚🚚
    //  *
    //  * @param int $s_area_id 出发地id(可不传)
    //  * @param int $e_area_id 目的地id(可不传)
    //  * @return void
    //  */
    // public function get_all_route($s_area_id=null,$e_area_id=null)
    // {
    //     $list = $this->GetAllRoute($s_area_id,$e_area_id);
    //     $this->success('ok',$list);
    // }
    

    /**
     * 搜索地址
     *
     * @param string $name 城市名
     * @param string $level 1省2市3区默认2
     * @return void
     */
    public function search_area($name = null,$level = 2)
    {
        switch ($level) {
            case '1':
                $where['name'] = ['like','%'.$name.'%'];
                $where['level'] = $level;
                break;
            case '2':
                $where['name'] = ['like','%'.$name.'%'];
                $where['level'] = $level;
                break;
            case '2':
                $where['name'] = ['like','%'.$name.'%'];
                $where['level'] = $level;
                break;
            default:
                # code...
                break;
        }
        $list = Db::name('area')->where($where)->select();
        $this->success('ok',$list);
    }

    /**
     * 获取全部路线🚚🚚
     *
     * @param string $name 路线名
     * @return void
     */
    public function search_all_route($name = null)
    {
        // $list = $this->GetAllRoute($s_area_id,$e_area_id);
        $where['name'] = ['like',"%".$name."%"];
        $list = Db::name('route')->where($where)->select();
        foreach ($list as $key => &$val) {
            $val['s_area'] = Db::name('area')->where('id',$val['s_area_id'])->value('name');
            $val['e_area'] = Db::name('area')->where('id',$val['e_area_id'])->value('name');
        }

        $this->success('ok',$list);
    }


    /**
     * 获取全部路线2🚚🚚
     *
     * @param string $s_name 出发城市名
     * @param string $e_name 目的城市名
     * @return void
     */
    public function search_all_route2($s_name = null,$e_name = null)
    {



        // $list = $this->GetAllRoute($s_area_id,$e_area_id);
        if($s_name && !$e_name){
            $where['name'] = ['like',"%".$s_name."%"];
        }

        if($s_name && $e_name){
            $where['name'] = ['like',"%".$s_name.'->'.$e_name."%"];
        }


        
        $list = Db::name('route')->where($where)->select();
        foreach ($list as $key => &$val) {
            $val['s_area'] = Db::name('area')->where('id',$val['s_area_id'])->value('name');
            $val['e_area'] = Db::name('area')->where('id',$val['e_area_id'])->value('name');
        }

        $this->success('ok',$list);
    }


    /**
    * 获取顺风单列表
    * @param string $s_city 始发城市
    * @param string $e_city 目的城市
    * @param integer $page 1
    * @param integer $limit 5
    * @return void
    */
    public function get_order_return_list($page=1,$limit=5,$s_city=null,$e_city=null)
    {
        
        // $where['s_uid'] = ['=',$this->auth->id];
        //  $status 状态:1=待接单,2=已接单,3=司机到达目的地,4=货主确认已装车,5=司机已确认送达,6=货主已确认收货,9=已取消
        $where['status'] = ['=','1'];
        if($s_city){
            $s_ids = $this->GetAddrCityIds($s_city);
            if($s_ids){
                $where['s_addr_id'] = ['in',$s_ids];
            }
        }

        if($e_city){
            $e_ids = $this->GetAddrCityIds($e_city);
            if($e_ids){
                $where['e_addr_id|e2_addr_id'] = ['in',$e_ids];
            }
        }
    
        $list = Db::name('order_return')->where($where)->page($page,$limit)->select();
        if($list){
            foreach ($list as $key => &$val) {
                $val = $this->GetOrder4FieldData($val);     
                $val['user'] = Db::name('user')->where('id',$val['j_uid'])->find();            
            }
        }




        $this->success('ok',$list);
    }



    /**
     * 预估价格转换订单1定金💰
     *
     * @param srting $money 预估价格
     * @return void
     */
    public function money_change_order1_deposit($money)
    {
        $res = $this->ChangeOrder1Deposit($money);
        $this->success('定金',$res);
    }


}
